import React, { Component } from 'react'

// 类组件button按钮事件
export default class ClassButton extends Component {
    state={
        num:1
    }
  render() {
    return (
        <>
            <div>数字为：{this.state.num}</div>
            <div><button onClick={this.addNum.bind(this)}>累加</button></div>
        </>
     
    )
  }
  addNum(){
    // 异步
    this.setState({
        num:this.state.num+1
    },()=>{
        console.log(this.state.num);
    })
  }
}
